package com.example.android_basequickadapter;

import android.support.design.widget.TabLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.helper.ItemTouchHelper;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity implements BaseQuickAdapter.OnItemClickListener, BaseQuickAdapter.OnItemLongClickListener {

    private RecyclerView testRecycler;
    private TestAdapter adapter;
    private List<String> list;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initActivity();
        setOperation();
        setLinstener();
    }

    private void initActivity() {



        testRecycler = findViewById(R.id.test_recycler);
        adapter = new TestAdapter(R.layout.item_test_list);
        list = new ArrayList<>();
    }

    private void setOperation() {



        /**
         * 添加适配器以及设置数据的排列方向
         */
        testRecycler.setLayoutManager( new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
        testRecycler.setAdapter(adapter);

        /**
         * 适配器的操作
         */
        adapter.openLoadAnimation(BaseQuickAdapter.SCALEIN);

//        ItemTouchHelper.Callback callback = new S1impleItemTouchHelperCallback(mAdapter);
//
//        ItemTouchHelper mItemTouchHelper = new ItemTouchHelper(callback);
//
//        adapter.setItemTouchHelper(mItemTouchHelper);
//
//        adapter.setDragViewId(R.id.iv_drag);
//
//        mItemTouchHelper.attachToRecyclerView(mRecyclerView);


        for (int i = 0; i < 500; i++) {
            list.add( " item  --> " + i);
        }

        adapter.setNewData( list);
    }

    private void setLinstener() {

        adapter.setOnItemLongClickListener(this);
    }

    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {

    }

    @Override
    public boolean onItemLongClick(BaseQuickAdapter adapter, View view, int position) {

        return true;
    }
}
